package com.zyl.blog.common.domain.file.bean;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

/**
 * @version v1.0
 * @ProjectName: Personal_Blog_Server
 * @Package: com.zyl.blog.common.domain.file.bean
 * @ClassName: AttachmentRelation
 * @Description: 附件关联表
 * @Author FinalFantasy
 * @Date 2025/8/14-09:20
 */
@Data
@ToString
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@TableName("attachment_relation")
public class AttachmentRelation {
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @JsonProperty("id")
    private Long id;

    /**
     * 文件ID
     */
    @TableField("file_id")
    @JsonProperty("fileId")
    private Long fileId;

    /**
     * 关联对象ID
     */
    @TableField("relation_id")
    @JsonProperty("relationId")
    private Long relationId;

    /**
     * 关联对象类型（如：article, comment等）
     */
    @TableField("relation_type")
    @JsonProperty("relationType")
    private String relationType;

    /**
     * 排序序号
     */
    @TableField("sort_order")
    @JsonProperty("sortOrder")
    private Integer sortOrder;

    /**
     * 是否主附件：0-否，1-是
     */
    @TableField("is_primary")
    @JsonProperty("isPrimary")
    private Integer isPrimary;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @JsonProperty(value = "createTime", access = JsonProperty.Access.READ_ONLY)
    private LocalDateTime createTime;

}